package xin.nick.minicat;

/**
 * @author Nick
 * @date 2021/6/20
 * @description
 */
public abstract class HttpServlet implements Servlet{

    public void service(Request request, Response response) throws Exception {
        if (RequestMethodEnum.GET.getMethod().equals(request.getMethod())) {
            doGet(request, response);
        } else if (RequestMethodEnum.POST.getMethod().equals(request.getMethod())) {
            doPost(request, response);
        } else {
            throw new RuntimeException("Http method is mismatch");
        }
    }

    public abstract void doGet(Request request, Response response);

    public abstract void doPost(Request request, Response response);
}
